export default {
    namespaced:true,
    state:()=>({
        adsList: [
            {
                id: '1',
                name: '张三',
                tel: '130000000000',
                address: '浙江省杭州市西湖区文三路 138 号',
                province:'浙江省',	
                city:'杭州市',	
                county:'西湖区',	
                addressDetail:'东方通信大厦 7 楼 501 室',	
                areaCode:'138 号',	
                postalCode:'302000',
                isDefault: true,
            },
            {
                id: '2',
                name: '李四',
                tel: '13100000000',
                address: '浙江省杭州市拱墅区莫干山路 50 号',
                province:'浙江省',	
                city:'杭州市',	
                county:'拱墅区',	
                addressDetail:'莫干山路 50 号',	
                areaCode:' 50 号',	
                postalCode:'400520',
                isDefault:false,
            },
        ],
        addressInfo:[{
            id: '1',
            name: '张三',
            tel: '130000000000',
            address: '浙江省杭州市西湖区文三路 138 号',
            province:'浙江省',	
            city:'杭州市',	
            county:'西湖区',	
            addressDetail:'东方通信大厦 7 楼 501 室',	
            areaCode:'138 号',	
            postalCode:'302000',
            isDefault: true,
        }]
    }),
    mutations:{
        addressAddMut(state,obj){    //通过editIdx来判断是执行新增、修改
            let {content,idx,i} =obj
            if(idx==-1){
                state.adsList.push(content)  //执行新增功能
            }else{
                if(i==-2){
                    state.adsList.splice(idx,1)    //删除功能
                }else{
                    state.adsList[idx] = content  //修改功能
                }
            }
        },
        addressInfo(state,obj){
            let {index,item} = obj
            console.log(index);
            state.addressInfo.splice(0,1,index)
        }
    }
}